<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="socket.io.js"></script>
</head>
<body>
        <textarea id="content"></textarea>
</body>
<script>
    var socket = io.connect('http://localhost:8000');
    socket.on('welcome', function (data) {
        document.body.innerHTML = data;
    });
    // 监听STC事件，接收别的好友的消息
    socket.on('STC',function(data){
        console.log('接收：'+data);
    })
    var content = document.queryCommandState('#content')
    content.onkeyup = function(e){
        if(e.keyCode == 13){
            socket.emit('CTS',this.value);
            this.value="";
        }
    }
</script>

</html>